<template>
  <div id="app-home">
    <app-header></app-header>
    <app-content v-bind:persons="persons"></app-content>
    <app-footer></app-footer>
  </div>
</template>

<script>
  import Header from './Header.vue';
  import Content from './Content.vue';
  import Footer from './Footer.vue';

  export default {
    name: 'app-home',
    data() {
      return {
        persons: []
      }
    },
    components: {
      'app-header': Header,
      'app-content': Content,
      'app-footer': Footer
    },
    // 在页面加载之前得到数据
    created() {
      this.$http.get("http://" +
        "jsonplaceholder.typicode.com/users")
          .then((data) => {
            // console.log(data)
            this.persons = data['body'];
            console.log(this.persons)

          })
    }
  }
</script>

<style>
  #app-home {
    font-family: 'Avenir', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
  }
</style>
